package site.lanmushan.framework.query.entity;


import org.springframework.beans.BeanUtils;

import java.lang.reflect.InvocationTargetException;

/**
 * @author Administrator
 */
public interface TransFormEntity {
    /**
     * 转换
     *
     * @param clazz
     * @param <T>
     * @return
     */
    default <T> T transformTo(Class<T> clazz) {
        try {
            T t = null;
            t = clazz.newInstance();
            BeanUtils.copyProperties(this, t);
            return t;
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

}
